/*    */ package com.zimbra.cs.service.admin;
/*    */ 
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.soap.AdminConstants;
/*    */ import com.zimbra.common.soap.Element;
/*    */ import com.zimbra.common.util.Pair;
/*    */ import com.zimbra.cs.account.Provisioning;
/*    */ import com.zimbra.cs.account.accesscontrol.AdminRight;
/*    */ import com.zimbra.cs.account.accesscontrol.GranteeType;
/*    */ import com.zimbra.cs.account.accesscontrol.RightCommand;
/*    */ import com.zimbra.cs.account.accesscontrol.RightCommand.EffectiveRights;
/*    */ import com.zimbra.cs.account.accesscontrol.Rights.Admin;
/*    */ import com.zimbra.cs.account.accesscontrol.TargetType;
/*    */ import com.zimbra.soap.ZimbraSoapContext;
/*    */ import com.zimbra.soap.admin.type.GranteeSelector.GranteeBy;
/*    */ import com.zimbra.soap.type.TargetBy;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class GetEffectiveRights
/*    */   extends RightDocumentHandler
/*    */ {
/*    */   public Element handle(Element request, Map<String, Object> context)
/*    */     throws ServiceException
/*    */   {
/* 40 */     ZimbraSoapContext zsc = getZimbraSoapContext(context);
/*    */     
/* 42 */     Pair<Boolean, Boolean> expandAttrs = parseExpandAttrs(request);
/* 43 */     boolean expandSetAttrs = ((Boolean)expandAttrs.getFirst()).booleanValue();
/* 44 */     boolean expandGetAttrs = ((Boolean)expandAttrs.getSecond()).booleanValue();
/*    */     
/* 46 */     Element eTarget = request.getElement("target");
/* 47 */     String targetType = eTarget.getAttribute("type");
/* 48 */     TargetBy targetBy = null;
/* 49 */     String target = null;
/* 50 */     if (TargetType.fromCode(targetType).needsTargetIdentity()) {
/* 51 */       targetBy = TargetBy.fromString(eTarget.getAttribute("by"));
/* 52 */       target = eTarget.getText();
/*    */     }
/*    */     
/* 55 */     Element eGrantee = request.getOptionalElement("grantee");
/*    */     String grantee;
/*    */     GranteeSelector.GranteeBy granteeBy;
/* 58 */     String grantee; if (eGrantee != null) {
/* 59 */       String granteeType = eGrantee.getAttribute("type", GranteeType.GT_USER.getCode());
/* 60 */       if (GranteeType.fromCode(granteeType) != GranteeType.GT_USER)
/* 61 */         throw ServiceException.INVALID_REQUEST("invalid grantee type " + granteeType, null);
/* 62 */       GranteeSelector.GranteeBy granteeBy = GranteeSelector.GranteeBy.fromString(eGrantee.getAttribute("by"));
/* 63 */       grantee = eGrantee.getText();
/*    */     } else {
/* 65 */       granteeBy = GranteeSelector.GranteeBy.id;
/* 66 */       grantee = zsc.getRequestedAccountId();
/*    */     }
/*    */     
/* 69 */     if (!grantee.equals(zsc.getAuthtokenAccountId())) {
/* 70 */       checkCheckRightRight(zsc, GranteeType.GT_USER, granteeBy, grantee);
/*    */     }
/*    */     
/* 73 */     RightCommand.EffectiveRights er = RightCommand.getEffectiveRights(Provisioning.getInstance(), targetType, targetBy, target, granteeBy, grantee, expandSetAttrs, expandGetAttrs);
/*    */     
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/* 79 */     Element resp = zsc.createElement(AdminConstants.GET_EFFECTIVE_RIGHTS_RESPONSE);
/* 80 */     er.toXML_getEffectiveRights(resp);
/* 81 */     return resp;
/*    */   }
/*    */   
/*    */   public void docRights(List<AdminRight> relatedRights, List<String> notes)
/*    */   {
/* 86 */     relatedRights.add(Rights.Admin.R_checkRightUsr);
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/admin/GetEffectiveRights.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */